@@ -11,8 +11,8 @@ class UserMessageInfoAdmin(admin.ModelAdmin): |
||
11 | 11 |
|
12 | 12 |
|
13 | 13 |
class SystemMessageInfoAdmin(admin.ModelAdmin): |
14 |
- list_display = ('title', 'content', 'url', 'status', 'created_at', 'updated_at') |
|
15 |
- list_filter = ('status', ) |
|
14 |
+ list_display = ('title', 'content', 'url', 'src', 'status', 'created_at', 'updated_at') |
|
15 |
+ list_filter = ('src', 'status') |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 |
class SystemMessageReadInfoAdmin(admin.ModelAdmin): |
@@ -0,0 +1,19 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+from __future__ import unicode_literals |
|
3 |
+ |
|
4 |
+from django.db import models, migrations |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class Migration(migrations.Migration): |
|
8 |
+ |
|
9 |
+ dependencies = [ |
|
10 |
+ ('message', '0005_auto_20160422_1322'), |
|
11 |
+ ] |
|
12 |
+ |
|
13 |
+ operations = [ |
|
14 |
+ migrations.AddField( |
|
15 |
+ model_name='systemmessageinfo', |
|
16 |
+ name='src', |
|
17 |
+ field=models.IntegerField(default=0, help_text='\u7cfb\u7edf\u6d88\u606f\u7c7b\u522b', verbose_name='src', choices=[(0, '\u62cd\u7231\u7528\u6237\u7aef'), (1, '\u62cd\u7231\u6444\u5f71\u5e08\u7aef')]), |
|
18 |
+ ), |
|
19 |
+ ] |
@@ -77,9 +77,18 @@ class UserMessageInfo(CreateUpdateMixin): |
||
77 | 77 |
|
78 | 78 |
|
79 | 79 |
class SystemMessageInfo(CreateUpdateMixin): |
80 |
+ PAIAI_USER = 0 |
|
81 |
+ PAIAI_LENSMAN = 1 |
|
82 |
+ |
|
83 |
+ SRC = ( |
|
84 |
+ (PAIAI_USER, u'拍爱用户端'), |
|
85 |
+ (PAIAI_LENSMAN, u'拍爱摄影师端'), |
|
86 |
+ ) |
|
87 |
+ |
|
80 | 88 |
title = models.CharField(_(u'title'), max_length=255, help_text=u'系统消息标题') |
81 | 89 |
content = models.TextField(_(u'content'), blank=True, null=True, help_text=u'系统消息内容') |
82 | 90 |
url = models.CharField(_(u'url'), max_length=255, blank=True, null=True, help_text=u'系统消息链接') |
91 |
+ src = models.IntegerField(_(u'src'), choices=SRC, default=PAIAI_USER, help_text=u'系统消息类别') |
|
83 | 92 |
|
84 | 93 |
class Meta: |
85 | 94 |
verbose_name = _('systemmessageinfo') |
@@ -30,6 +30,7 @@ def message_list_api(request): |
||
30 | 30 |
read_message_ids = get_system_message_read_info(user_id) |
31 | 31 |
deleted_message_ids = get_system_message_delete_info(user_id) |
32 | 32 |
type_unread_messages = SystemMessageInfo.objects.filter( |
33 |
+ src=SystemMessageInfo.PAIAI_USER, |
|
33 | 34 |
status=True, |
34 | 35 |
).exclude( |
35 | 36 |
pk__in=list(set(read_message_ids + deleted_message_ids)), |
@@ -64,6 +65,7 @@ def message_type_list_api(request, msg_type): |
||
64 | 65 |
if msg_type == UserMessageInfo.SYSTEM: |
65 | 66 |
deleted_message_ids = get_system_message_delete_info(user_id) |
66 | 67 |
type_messages = SystemMessageInfo.objects.filter( |
68 |
+ src=SystemMessageInfo.PAIAI_USER, |
|
67 | 69 |
status=True, |
68 | 70 |
).exclude( |
69 | 71 |
pk__in=deleted_message_ids, |
@@ -110,7 +112,7 @@ def message_type_read_api(request, msg_type=None): |
||
110 | 112 |
return response(MessageStatusCode.MESSAGE_NOT_FOUND) |
111 | 113 |
SystemMessageReadInfo.objects.get_or_create(user_id=user_id, msg_id=pk) |
112 | 114 |
if _all == 'true': # 系统消息全部读取 |
113 |
- for msg in SystemMessageInfo.objects.filter(status=True): |
|
115 |
+ for msg in SystemMessageInfo.objects.filter(src=SystemMessageInfo.PAIAI_USER, status=True): |
|
114 | 116 |
SystemMessageReadInfo.objects.get_or_create(user_id=user_id, msg_id=msg.pk) |
115 | 117 |
get_system_message_read_info(user_id) |
116 | 118 |
else: |
@@ -147,7 +149,7 @@ def message_type_delete_api(request, msg_type=None): |
||
147 | 149 |
return response(MessageStatusCode.MESSAGE_NOT_FOUND) |
148 | 150 |
SystemMessageDeleteInfo.objects.get_or_create(user_id=user_id, msg_id=pk) |
149 | 151 |
if _all == 'true': # 系统消息全部删除 |
150 |
- for msg in SystemMessageInfo.objects.filter(status=True): |
|
152 |
+ for msg in SystemMessageInfo.objects.filter(src=SystemMessageInfo.PAIAI_USER, status=True): |
|
151 | 153 |
SystemMessageDeleteInfo.objects.get_or_create(user_id=user_id, msg_id=msg.pk) |
152 | 154 |
set_system_message_delete_info(user_id) |
153 | 155 |
else: |